package com.cxps.cloud.enums;

import java.util.HashMap;
import java.util.Map;

/**
 * 销售方式枚举类
 *
 * @author YouCai.Liu
 * @since 2021/10/8
 * ...
 */
public enum SaleTypeEnum {

    OFF_LINE(0, "计件"),
    ON_LINE(1, "计重");

    private final static Map<Integer, SaleTypeEnum> CODE_MAP = new HashMap();
    private final static Map<String, SaleTypeEnum> NAME_MAP = new HashMap();

    static {
        for (SaleTypeEnum status : values()) {
            CODE_MAP.put(status.getCode(), status);
            NAME_MAP.put(status.getName(), status);
        }
    }

    private Integer code;

    private String name;

    SaleTypeEnum(Integer code, String name) {
        this.code = code;
        this.name = name;
    }

    public static SaleTypeEnum getEnumByCode(Integer code) {
        return CODE_MAP.get(code);
    }

    public static SaleTypeEnum getEnumByName(String name) {
        return NAME_MAP.get(name);
    }

    public Integer getCode() {
        return code;
    }

    public String getName() {
        return name;
    }
}
